﻿#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QFileDialog>
#include <QMessageBox>

/* *
 * 车牌识别Demo, 使用百度智能云的接口， 进行车牌号识别
 */


Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
  ,selectFile("")
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::on_btnSelectFile_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(nullptr, "选择图片", "", "files(*)");
    if(!fileName.isEmpty())
    {
        selectFile = fileName;
        ui->labelImage->setPixmap(QPixmap(fileName));
    }
}

void Widget::on_btnOcr_clicked()
{
    if(!selectFile.isEmpty())
    {
        QStringList list = service.getCardId(selectFile);
        QMessageBox::information(this, "结果", QString("车牌颜色：%1\n车牌号:%2").arg(list.at(0)).arg(list.at(1)));
    }
}
